package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.system.domain.req.SysTranServiceReq;
import com.ruoyi.system.domain.vo.SysTransactionServiceDto;
import com.ruoyi.system.domain.vo.SysTransactionDtlDto;
import jakarta.annotation.security.PermitAll;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysTransactionService;
import com.ruoyi.system.service.ISysTransactionServiceService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 交易服务模板信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-28
 */
@RestController
@RequestMapping("/service")
public class SysTransactionServiceController extends BaseController
{
    @Autowired
    private ISysTransactionServiceService sysTransactionServiceService;

    /**
     * 查询交易服务模板信息列表
     */
    @RequiresPermissions("system:service:list")
    @GetMapping("/list")
    public TableDataInfo list(SysTransactionService sysTransactionService)
    {
        startPage();
        List<SysTransactionService> list = sysTransactionServiceService.selectSysTransactionServiceList(sysTransactionService);
        return getDataTable(list);
    }


    /**
     * 获取交易服务模板信息详细信息
     */
    @RequiresPermissions("system:service:query")
    @GetMapping(value = "/{modualId}")
    public AjaxResult getInfo(@PathVariable("modualId") Long modualId)
    {
        return success(sysTransactionServiceService.selectSysTransactionServiceByModualId(modualId));
    }

    /**
     * 新增交易服务模板信息
     */
    @RequiresPermissions("system:service:add")
    @Log(title = "交易服务模板信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysTransactionService sysTransactionService)
    {
        return toAjax(sysTransactionServiceService.insertSysTransactionService(sysTransactionService));
    }

    /**
     * 修改交易服务模板信息
     */
    @RequiresPermissions("system:service:edit")
    @Log(title = "交易服务模板信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody SysTransactionService sysTransactionService)
    {
        return toAjax(sysTransactionServiceService.updateSysTransactionService(sysTransactionService));
    }

    /**
     * 删除交易服务模板信息
     */
    @RequiresPermissions("system:service:remove")
    @Log(title = "交易服务模板信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modualIds}")
    public AjaxResult remove(@PathVariable Long[] modualIds)
    {
        return toAjax(sysTransactionServiceService.deleteSysTransactionServiceByModualIds(modualIds));
    }

    /**
     * 查询B,C交易服务模板信息列表
     */
    @PermitAll
    @GetMapping("/modualList")
    public TableDataInfo modualList(@RequestParam  String saleType)
    {
        startPage();
        List<SysTransactionService> list = sysTransactionServiceService.selectSysTransactionServiceListBySaleType(saleType);
        return getDataTable(list);
    }


    /**
     * 状态变更
     */
    @PermitAll
    @GetMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestParam Long moduleId, String isEnabled)
    {
        return toAjax(sysTransactionServiceService.changeStatus(moduleId,isEnabled));

    }

    /**
     * 搜索
     */
    @PermitAll
    @PostMapping("/getUserList")
    public TableDataInfo getUserList(@RequestBody SysTranServiceReq sysTranServiceReq)
    {
        return sysTransactionServiceService.getUserList(sysTranServiceReq);

    }

    /**
     * 查看详情
     */
    @PermitAll
    @GetMapping("/viewDetail")
    public TableDataInfo viewDetail(SysTransactionService sysTransactionService){

      return sysTransactionServiceService.viewDetail(sysTransactionService);

    }
}
